﻿using System;
using System.Xml.Linq;

namespace YArchitech.Temp.Fluid
{
	public class Water : IComparable, IHYXmlSerial
	{
		public int Temperature { get; set; }

		public double Density { get; set; }

		public double SpecificHeat { get; set; }

		public double Viscosity { get; set; }

		public int CompareTo(object obj)
		{
			if (obj is Water)
			{
				Water water = obj as Water;
				return this.Temperature - water.Temperature;
			}
			return 1;
		}

		public static bool operator <(Water left, Water right)
		{
			return left.Temperature < right.Temperature;
		}

		public static bool operator >(Water left, Water right)
		{
			return left.Temperature > right.Temperature;
		}

		public void ReadXml(XElement xe)
		{
			this.Temperature = (int)xe.Attribute("Temperature");
			this.Density = (double)xe.Attribute("Density");
			this.SpecificHeat = (double)xe.Attribute("SpecificHeat");
			this.Viscosity = (double)xe.Attribute("Viscosity");
		}

		public void WriteXml(XElement xe)
		{
			xe.Add(new XAttribute("Temperature", this.Temperature));
			xe.Add(new XAttribute("Density", this.Density));
			xe.Add(new XAttribute("SpecificHeat", this.SpecificHeat));
			xe.Add(new XAttribute("Viscosity", this.Viscosity));
		}
	}
}
